﻿@{
   
}
@section head{
    <link href="@Url.Content("~/CSS/Page.css")" rel="stylesheet" type="text/css" />
}
<div class="rightbar">
    <p class="righttit">
        <span>管理中心</span></p>
    <div class="rightshow">
        <div class="listshow">
            <form method="get" id="searchForm" action="@Url.Content("~/admin/ProMgr/ProductList")">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="80px">
                        产品分类：
                    </td>
                    <td width="150px">
                        <select name="TypeId" class="select">
                            <option value="">全部分类</option>
                            @helper renderProType(string pid, string parentName)
                                {
                                    System.Data.DataView dv = new System.Data.DataView(@ViewBag.Product_IndustryDt);
                                    dv.RowFilter = "[parentId]=" + pid;

                                    foreach (System.Data.DataRowView drv in dv)
                                    {
                                        string priname = parentName + (parentName.Length == 0 ? "" : "-") + drv["IndustryName"];
                                        string id = drv["id"].ToString();
                                <option  value="@id" @(int.Parse(id) == @Model.TypeId ? "selected" : "")>
                                    @MvcHtmlString.Create(parentName)@MvcHtmlString.Create("└" + @drv["IndustryName"].ToString())
                                </option>
                                @renderProType(id, drv["IndustryName"].ToString());
                                    }
                            }
                            @renderProType("0", "")
                        </select>
                    </td>
                    <td width="80px">
                        产品关键词：
                    </td>
                    <td width="260px">
                        <input type="text" name="SearchKey" id="SearchKey" class="input2 text" value="@Request["SearchKey"]"/>
                    </td>
                    <td width="80px">
                        状态：
                    </td>
                    <td width="260px">
                        <select name="Status" id="Status" class="select">
                            <option value="0"  @(@ViewBag.Status == 0 ? "selected" : "")>待审</option>
                            <option value="1"  @(@ViewBag.Status == 1 ? "selected" : "")>通过</option>
                            <option value="-1"  @(@ViewBag.Status == -1 ? "selected" : "")>删除</option>
                            <option value="-2"  @(@ViewBag.Status == -2 ? "selected" : "")>拒绝</option>
                        </select>
                    </td>
                    <td>
                        <a href="javascript:void(0);" onclick="javascript:searchForm.submit();" class="sbtn">
                            <span class="white">搜索</span></a>
                    </td>
                </tr>
            </table>
            </form>
        </div>
@*        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabtit">
            <tr>
                <td width="10%" align="center">
                    <a href="@Url.Action("ProInfoDetail")">
                        <img alt="" src="@Url.Content("~/Areas/admin/image/add.jpg")" />
                        添加产品</a>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
        </table>*@
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tinfor1">
            <tr class="tinfor2">
                <td width="3%">
                    <input type="checkbox" name="checkbox" />
                </td>
                <td width="4%">
                  编号
                </td>
                <td>
                    产品标题
                </td>
                <td>
                    原价
                </td>
                <td>
                    现价
                </td>
                <td>
                    批发价
                </td>
                 <td>
                    发布时间
                </td>
                <td>
                    操作
                </td>
            </tr>
            @foreach (var single in @Model.Rows)
            {
                <tr class="tinfor3">
                    <td>
                        <input type="checkbox" name="checkbox" />
                    </td>
                    <td>
                     @single["Id"]
                        @*<input type="text" class="Sort" id="@single["Id"]" value="@single["Sort"]"  style="width:30px"/>*@
                    </td>
                    <td>
                        @single["Title"]
                    </td>
                    <td>
                        @single["OldPrice"]
                    </td>
                    <td>
                        @single["CurrentPrice"]
                    </td>
                    <td>
                        @single["TradePrice"]
                    </td>
                     <td>
                        @single["UpdateTime"].ToString("yyyy-MM-dd")
                    </td>
                    <td>
                        <a href="@Url.Action("ProInfoDetail", "ProMgr", new { id = @single["Id"] })" id="update">
                            修改</a>|
                        @helper renderStatus(int status, int id)
                            {
                                if (status == (int)SYH.Enum.ProStatus.拒绝)
                                {
                            <a href="#" id="grounding" onclick='oDelete("pass",@id)'>通过</a>
                                }
                                else
                                {
                            <a href="#" id="soldout" onclick='oSoldout("unpass",@id)'>拒绝</a>
                                }
                        }
                        @renderStatus(@single["Status"], @single["Id"])
                        | <a href="#" id="delete" onclick='oDelete("delete",@single["Id"])'>删除</a>
                    </td>
                </tr>
            }
            <tr>
                <td colspan="10">
                    @MvcHtmlString.Create(@ViewBag.pageBar)
                </td>
            </tr>
        </table>
    </div>
</div>
@section Script{
    <script type="text/javascript">
        //删除
        function oDelete(action, obj) {
            art.dialog.confirm('你确定要删除吗？', function () {
                doOper(action, obj);
            }, function () {

            });
        }

        //下架
        function oSoldout(action, obj) {
            art.dialog.confirm('你确定要拒绝吗？', function () {
                doOper(action, obj);
            }, function () {

            });
        }

        //具体操作
        function doOper(action, obj, sortValue) {
            $.ajax({
                type: "POST",
                url: "/Admin/ProMgr/ProInfoOper",
                data: { "id": obj, "action": action, "sort": sortValue },
                dataType: "text",
                success: function (msg) {
                    if (msg == "1") {
                        location.reload();
                    }
                    else {
                        art.dialog({
                            title: "提示",
                            icon: "warning",
                            content: "操作失败！",
                            time: 2
                        });
                    }
                },
                error: function () {
                    art.dialog({
                        title: "提示",
                        icon: "warning",
                        content: "网络忙，请稍后再试！",
                        time: 2
                    });
                }
            });
        }

        //        //为排序字段赋值
        //        $(function () {
        //            $(".Sort").each(function () {
        //                $(this).blur(function () {
        //                    var id = $(this).attr("id");
        //                    var value = $(this).attr("value");
        //                    doOper("sort", id, value);
        //                });
        //            });
        //        });
    </script>
}
